package org.road0329.tools.proto_parse_tool.ems.qgdw3761.utils;

import org.road0329.tools.proto_parse_tool.chargingpile.MsgDcsResult;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2018-09-13.
 */
@Component
public class Gw09ComfirmUtil {

    public static MsgDcsResult parseACKData(byte[] msg, int from, boolean acd) {
        int index = from;
        int fixlen = (msg[index] & 0x80) == 0 ? 2 : 8;
        if (acd) {
            fixlen += 2;
        }
        index++;
        MsgDcsResult gwResult = new MsgDcsResult();
        if (msg[index + 2] == 0x01) {
            gwResult.setMessage("全部确认");
            gwResult.setSuccess(true);
            index += 4;
        } else if (msg[index + 2] == 0x02) {
            gwResult.setMessage("全部否认");
            gwResult.setSuccess(false);
            index += 4;
        } else if (msg[index + 2] == 0x03) {
            StringBuffer buffer = new StringBuffer("");
            gwResult.setMessage("部分否认");
            gwResult.setSuccess(false);
            index += 4;
            //AFN（要被确认的报文的AFN）
            index++;
        } else {
            gwResult.setMessage("未知错误");
            gwResult.setSuccess(false);
        }
        return gwResult;
    }

}
